package service

import (
	"ruoyi-go/app/dto"
	"ruoyi-go/app/token"
	"ruoyi-go/common/types/constant"
)

type UserWeb3 struct{}

/**
 *   添加用户 默认角色
 */
func (*UserWeb3) LoginWebs3(id string) (string, error) {

	user := dto.SaveUser{
		UserName: id,
		NickName: id,
		CreateBy: "System",
		Status:   "0",
	}

	service_user := &UserService{}

	user_exist := service_user.GetUserByUsername(id)
	if user_exist.UserId <= 0 || user_exist.Status != constant.NORMAL_STATUS {
		(&UserService{}).CreateUser(user, []int{2}, []int{2})
		user_exist = service_user.GetUserByUsername(id)
	}
	return token.GetClaims().GenerateToken(user_exist)
}
